Skip to content
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

[SYCL] multi_ptr class: fixes for conversion to void multi_ptr #57

Merged
merged 1 commit into from
Apr 3, 2019
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
15 changes: 13 additions & 2 deletions sycl/include/CL/sycl/multi_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,11 @@ template <typename ElementType, access::address_space Space> class multi_ptr {
return reinterpret_cast<ElementType *>(m_Pointer);
}

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

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

// TODO: this constructor is a temporary solution for the cases where
// the conversion to void multi pointer is used. Without it the compiler
// fails due to having 3 different same rank paths available.
// The issue is being discussed in Khronos groups now.
// See https://gitlab.khronos.org/sycl/Specification/issues/215 for details.
template <typename ElementType>
multi_ptr(const multi_ptr<ElementType, Space> &ETP) : m_Pointer(ETP.get()) {}

// Assignment operators
multi_ptr &operator=(const multi_ptr &) = default;
multi_ptr &operator=(multi_ptr &&) = default;
Expand Down