Skip to content

Commit

Permalink
Merge pull request #439 from mmoadeli/impl-spec-mismatch
Browse files Browse the repository at this point in the history
[SYCL] Address multi_ptr in spec vs intel/llvm mismatches

Remove the 'explicit' keyword from the multi_ptr::operator pointer() function.
Include a generic space constraint in the multi_ptr::ctor from accessor and accessor(local) to support generic_space.
Implement the multi_ptr::ctor from local_accessor, including support for generic_space.
Enable implicit conversion of multi_ptr from accessors with const types.
Add deduction guides for the deprecated access::target::constant_buffer and access::target::local.
Implement support for the constant_space specialization of non-legacy multi_ptr.
  • Loading branch information
keryell committed Jul 20, 2023
1 parent 07785d6 commit ea8898c
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 14 deletions.
6 changes: 0 additions & 6 deletions adoc/chapters/programming_interface.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9822,12 +9822,6 @@ bool operator>=(std::nullptr_t, const multi_ptr& rhs)
The following is the overview of the legacy interface from 1.2.1 provided
for the [code]#multi_ptr# class.

This legacy class supports the deprecated [code]#address_space::constant_space#
address space, which can be used to represent a pointer to <<constant-memory>>.
Pointers to <<constant-memory>> have an implementation-defined address space,
and each implementation can define whether it is legal to assign such a pointer
to a generic address pointer.

[source,,linenums]
----
include::{header_dir}/multipointerlegacy.h[lines=4..-1]
Expand Down
27 changes: 26 additions & 1 deletion adoc/headers/multipointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ class multi_ptr {
multi_ptr(
accessor<AccDataT, Dimensions, Mode, target::local, IsPlaceholder>);

// Deprecated
// Available only when:
// Space == access::address_space::constant_space &&
// (std::is_same_v<std::remove_const_t<ElementType>, std::remove_const_t<AccDataT>>) &&
// (std::is_const_v<ElementType> || !std::is_const_v<AccDataT>)
template <typename AccDataT, int Dimensions, access::placeholder IsPlaceholder>
multi_ptr(
accessor<AccDataT, Dimensions, access_mode::read, target::constant_buffer, IsPlaceholder>);

// Assignment and access operators
multi_ptr& operator=(const multi_ptr&);
multi_ptr& operator=(multi_ptr&&);
Expand Down Expand Up @@ -296,6 +305,14 @@ class multi_ptr<VoidType, Space, DecorateAddress> {
multi_ptr(
accessor<ElementType, Dimensions, Mode, target::local, IsPlaceholder>);

// Deprecated
// Available only when:
// Space == access::address_space::constant_space &&
// (std::is_const_v<VoidType> || !std::is_const_v<ElementType>)
template <typename ElementType, int Dimensions, access::placeholder IsPlaceholder>
multi_ptr(
accessor<ElementType, Dimensions, access_mode::read, target::constant_buffer, IsPlaceholder>);

// Assignment operators
multi_ptr& operator=(const multi_ptr&);
multi_ptr& operator=(multi_ptr&&);
Expand All @@ -304,7 +321,7 @@ class multi_ptr<VoidType, Space, DecorateAddress> {
pointer get() const;

// Conversion to the underlying pointer type
explicit operator pointer() const;
operator pointer() const;

// Explicit conversion to a multi_ptr<ElementType>
// Available only when: (std::is_const_v<ElementType> || !std::is_const_v<VoidType>)
Expand Down Expand Up @@ -384,6 +401,14 @@ template <typename T, int Dimensions, access::placeholder IsPlaceholder>
multi_ptr(accessor<T, Dimensions, access_mode::read_write, target::device, IsPlaceholder>)
-> multi_ptr<T, access::address_space::global_space, access::decorated::no>;

template <typename T, int Dimensions, access::placeholder IsPlaceholder>
multi_ptr(accessor<T, Dimensions, access_mode::read, target::constant_buffer, IsPlaceholder>)
-> multi_ptr<const T, access::address_space::constant_space, access::decorated::no>;

template <typename T, int Dimensions, access_mode Mode, access::placeholder IsPlaceholder>
multi_ptr(accessor<T, Dimensions, Mode, target::local, IsPlaceholder>)
-> multi_ptr<T, access::address_space::local_space, access::decorated::no>;

template <typename T, int Dimensions>
multi_ptr(local_accessor<T, Dimensions>)
-> multi_ptr<T, access::address_space::local_space, access::decorated::no>;
Expand Down
47 changes: 40 additions & 7 deletions adoc/headers/multipointerlegacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,34 @@ class [[deprecated]] multi_ptr<ElementType, Space, access::decorated::legacy> {
}
ElementType* operator->() const;

// Only if Space == global_space
// Available only when:
// (Space == access::address_space::global_space ||
// Space == access::address_space::generic_space) &&
// (std::is_same_v<std::remove_const_t<ElementType>, std::remove_const_t<AccDataT>>) &&
// (std::is_const_v<ElementType> ||
// !std::is_const_v<accessor<AccDataT, Dimensions, Mode, target::device,
// IsPlaceholder>::value_type>)
template <int Dimensions, access_mode Mode, access::placeholder IsPlaceholder>
multi_ptr(
accessor<ElementType, Dimensions, Mode, target::device, IsPlaceholder>);

// Only if Space == local_space
// Available only when:
// (Space == access::address_space::local_space ||
// Space == access::address_space::generic_space) &&
// (std::is_same_v<std::remove_const_t<ElementType>, std::remove_const_t<AccDataT>>) &&
// (std::is_const_v<ElementType> || !std::is_const_v<AccDataT>)
template <int Dimensions, access_mode Mode, access::placeholder IsPlaceholder>
multi_ptr(
accessor<ElementType, Dimensions, Mode, target::local, IsPlaceholder>);

// Available only when:
// (Space == access::address_space::local_space ||
// Space == access::address_space::generic_space) &&
// (std::is_same_v<std::remove_const_t<ElementType>, std::remove_const_t<AccDataT>>) &&
// (std::is_const_v<ElementType> || !std::is_const_v<AccDataT>)
template <typename AccDataT, int Dimensions>
multi_ptr(local_accessor<AccDataT, Dimensions>);

// Only if Space == constant_space
template <int Dimensions, access_mode Mode, access::placeholder IsPlaceholder>
multi_ptr(accessor<ElementType, Dimensions, Mode, target::constant_buffer,
Expand All @@ -69,11 +87,11 @@ class [[deprecated]] multi_ptr<ElementType, Space, access::decorated::legacy> {
operator ElementType*() const;

// Implicit conversion to a multi_ptr<void>
// Only available when ElementType is not const-qualified
// Available only when ElementType is not const-qualified
operator multi_ptr<void, Space, access::decorated::legacy>() const;

// Implicit conversion to a multi_ptr<const void>
// Only available when ElementType is const-qualified
// Available only when ElementType is const-qualified
operator multi_ptr<const void, Space, access::decorated::legacy>() const;

// Implicit conversion to multi_ptr<const ElementType, Space>
Expand Down Expand Up @@ -176,15 +194,30 @@ class [[deprecated]] multi_ptr<VoidType, Space, access::decorated::legacy> {
multi_ptr& operator=(VoidType*);
multi_ptr& operator=(std::nullptr_t);

// Only if Space == global_space
// Available only when:
// (Space == access::address_space::global_space ||
// Space == access::address_space::generic_space) &&
// (std::is_const_v<VoidType> ||
// !std::is_const_v<accessor<ElementType, Dimensions, Mode, target::device,
// IsPlaceholder>::value_type>)
template <typename ElementType, int Dimensions, access_mode Mode>
multi_ptr(accessor<ElementType, Dimensions, Mode, target::device>);

// Only if Space == local_space
// Available only when:
// (Space == access::address_space::local_space ||
// Space == access::address_space::generic_space) &&
// (std::is_const_v<VoidType> || !std::is_const_v<ElementType>)
template <typename ElementType, int Dimensions, access_mode Mode>
multi_ptr(accessor<ElementType, Dimensions, Mode, target::local>);

// Only if Space == constant_space
// Available only when:
// (Space == access::address_space::local_space ||
// Space == access::address_space::generic_space) &&
// (std::is_const_v<VoidType> || !std::is_const_v<ElementType>)
template <typename AccDataT, int Dimensions>
multi_ptr(local_accessor<AccDataT, Dimensions>);

// Only if Space == access::address_space::constant_space
template <typename ElementType, int Dimensions, access_mode Mode>
multi_ptr(accessor<ElementType, Dimensions, Mode, target::constant_buffer>);

Expand Down

0 comments on commit ea8898c

Please sign in to comment.