Skip to content

Commit edb3d6d

Browse files
v-klochkovvladimirlaz
authored andcommitted
[SYCL] multi_ptr class: fixes for conversion to void multi_ptr
Signed-off-by: Vyacheslav N Klochkov <[email protected]>
1 parent 474c934 commit edb3d6d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

sycl/include/CL/sycl/multi_ptr.hpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,11 @@ template <typename ElementType, access::address_space Space> class multi_ptr {
126126
return reinterpret_cast<ElementType *>(m_Pointer);
127127
}
128128

129-
// Explicit conversion to a multi_ptr<void>
130-
explicit operator multi_ptr<void, Space>() const;
129+
// Implicit conversion to a multi_ptr<void>
130+
operator multi_ptr<void, Space>() const {
131+
using void_ptr_t = typename detail::PtrValueType<void, Space>::type *;
132+
return multi_ptr<void, Space>(reinterpret_cast<void_ptr_t>(m_Pointer));
133+
};
131134

132135
// Arithmetic operators
133136
multi_ptr &operator++() {
@@ -210,6 +213,14 @@ template <access::address_space Space> class multi_ptr<void, Space> {
210213
multi_ptr(std::nullptr_t) : m_Pointer(nullptr) {}
211214
~multi_ptr() = default;
212215

216+
// TODO: this constructor is a temporary solution for the cases where
217+
// the conversion to void multi pointer is used. Without it the compiler
218+
// fails due to having 3 different same rank paths available.
219+
// The issue is being discussed in Khronos groups now.
220+
// See https://gitlab.khronos.org/sycl/Specification/issues/215 for details.
221+
template <typename ElementType>
222+
multi_ptr(const multi_ptr<ElementType, Space> &ETP) : m_Pointer(ETP.get()) {}
223+
213224
// Assignment operators
214225
multi_ptr &operator=(const multi_ptr &) = default;
215226
multi_ptr &operator=(multi_ptr &&) = default;

0 commit comments

Comments
 (0)