================
@@ -873,6 +873,107 @@ expression.
}];
}
+def SYCLAddressSpaceDocs : Documentation {
+ let Category = DocCatType;
+ let Heading = "SYCL Address Spaces";
+ let Content = [{
+.. note::
+
+ These attributes are intended for use in the implementation of SYCL run-time
+ libraries and should not be used in any other context.
+ Programmers writing code intended to conform to the SYCL specification
should
+ use the address space facilities specified in the following sections of the
+ SYCL 2020 specification.
+
+ * `4.7.2, "Buffers" <SYCL-2020-4.7.2_>`_
+ * `4.7.6, "Accessors" <SYCL-2020-4.7.6_>`_.
+ * `4.7.7, "Address space classes" <SYCL-2020-4.7.7_>`_.
+ * `F.7, "sycl_khr_static_addrspace_cast" <SYCL-2020-F.7_>`_.
+ * `F.8, "sycl_khr_dynamic_addrspace_cast" <SYCL-2020-F.8_>`_.
+
+The SYCL address space attributes listed below correspond to the five address
+spaces described by
+`SYCL 2020 section 3.8.2, "SYCL device memory model" <SYCL-2020-3.8.2_>`_ and
+`SYCL 2020 section 4.7.7, "Address space classes" <SYCL-2020-4.7.7_>`_.
+
+.. list-table::
+ :header-rows: 1
+
+ * - Address space attribute
+ - SYCL address space
+ - Description
+ * - ``[[clang::sycl_global]]``
+ - global
+ - A memory region accessible by all work-items executing on a device.
+ * - ``[[clang::sycl_local]]``
+ - local
+ - A memory region accessible by all work-items of a single work-group.
+ * - ``[[clang::sycl_private]]``
+ - private
+ - A memory region that is private to a single work-item.
+ * - ``[[clang::sycl_generic]]``
+ - generic
+ - A virtual memory region from which the global, local, and private memory
+ regions may all be accessed.
+ * - ``[[clang::sycl_constant]]``
+ - constant
+ - (*deprecated*) A memory region that holds constant data for an executing
+ kernel.
+
+The SYCL address space attributes are type attributes that may be applied to
+the object type of an object pointer or object reference type.
+A type specifier with a SYCL address space specifies a distinct type from the
+otherwise unattributed type.
+For example, ``int *`` and ``int [[clang::sycl_global]]*`` designate distinct
+pointer types which participate in overload resolution and template
+specialization.
+
+Conversions between SYCL address space attributed types are permitted as
+follows.
+
+* Types attributed with the global, local, or private address space attributes
+ are implicitly convertible to matching types with the generic address space
+ attribute.
+* Types attributed with the generic address space attribute may be converted
----------------
elizabethandrews wrote:
I spent some time trying to understand the casting behavior. In the current
code Implicit casts work from named to generic. The converse is not allowed in
[C++](https://godbolt.org/z/bGEEaxMvM) or [OpenCL
mode](https://godbolt.org/z/e7T9e93Eo). ` static_cast` and `reinterpret_cast`
behave exactly like implicit conversion - [OpenCL
](https://godbolt.org/z/5MMhWTsYr), [C++](https://godbolt.org/z/86xKqWoK3) .
From my understanding this is by design. This [RFC
](https://lists.llvm.org/pipermail/cfe-dev/2018-December/060546.html) seems to
imply implicit, static and reinterpret casts should behave identically. For
generic to named narrowing, address space cast is required. This cast is
[openCL ](https://godbolt.org/z/dWYa3jc4b) only.
C style casts allow named to generic and converse conversions for
[openCL](https://godbolt.org/z/98x4dKWWE). It disallows conversion between
disjoint address spaces. In [C++](https://godbolt.org/z/P5d83joGo) it seems to
allow all which I assume is a bug,
https://github.com/llvm/llvm-project/pull/200849
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits