|
| 1 | += SYCL_INTEL_bitcast |
| 2 | + |
| 3 | +:source-highlighter: coderay |
| 4 | +:coderay-linenums-mode: table |
| 5 | + |
| 6 | +// This section needs to be after the document title. |
| 7 | +:doctype: book |
| 8 | +:toc2: |
| 9 | +:toc: left |
| 10 | +:encoding: utf-8 |
| 11 | +:lang: en |
| 12 | + |
| 13 | +:blank: pass:[ +] |
| 14 | + |
| 15 | +// Set the default source code type in this document to C++, |
| 16 | +// for syntax highlighting purposes. This is needed because |
| 17 | +// docbook uses c++ and html5 uses cpp. |
| 18 | +:language: {basebackend@docbook:c++:cpp} |
| 19 | + |
| 20 | +// This is necessary for asciidoc, but not for asciidoctor |
| 21 | +:cpp: C++ |
| 22 | + |
| 23 | +== Introduction |
| 24 | +IMPORTANT: This specification is a draft. |
| 25 | + |
| 26 | +NOTE: Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are |
| 27 | +trademarks of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc. |
| 28 | +used by permission by Khronos. |
| 29 | + |
| 30 | +NOTE: This document is better viewed when rendered as html with asciidoctor. |
| 31 | +GitHub does not render image icons. |
| 32 | + |
| 33 | +This document describes an extension that allows reinterpreting bits in a data |
| 34 | +type as another data type. |
| 35 | + |
| 36 | +== Name Strings |
| 37 | + |
| 38 | ++SYCL_INTEL_bitcast+ |
| 39 | + |
| 40 | +== Notice |
| 41 | + |
| 42 | +Copyright (c) 2020 Intel Corporation. All rights reserved. |
| 43 | + |
| 44 | +== Status |
| 45 | + |
| 46 | +Working Draft |
| 47 | + |
| 48 | +This is a preview extension specification, intended to provide early access to |
| 49 | +a feature for review and community feedback. When the feature matures, this |
| 50 | +specification may be released as a formal extension. |
| 51 | + |
| 52 | +Because the interfaces defined by this specification are not final and are |
| 53 | +subject to change they are not intended to be used by shipping software |
| 54 | +products. |
| 55 | + |
| 56 | +== Version |
| 57 | + |
| 58 | +Built On: {docdate} + |
| 59 | +Revision: 1 |
| 60 | + |
| 61 | +== Contact |
| 62 | +Felipe de Azevedo Piovezan, Intel (felipe 'dot' de 'dot' azevedo 'dot' piovezan 'at' intel 'dot' com) |
| 63 | + |
| 64 | +== Dependencies |
| 65 | + |
| 66 | +This extension is written against the SYCL 1.2.1 specification, Revision 6. |
| 67 | + |
| 68 | +== Overview |
| 69 | + |
| 70 | +It is frequently necessary to reinterpret the bits of an object as an object of |
| 71 | +a different data type. Several methods to achieve this conversion exist but |
| 72 | +most result in undefined behavior according to the {cpp} language. This |
| 73 | +extension defines the function `sycl::bit_cast` to convert between data types |
| 74 | +of the same size. The semantics of `sycl::bit_cast` are aligned with those of |
| 75 | +`std::bit_cast`, which will be introduced by the {cpp}20 language (p0476r2). |
| 76 | + |
| 77 | +== Modifications of SYCL 1.2.1 Specification |
| 78 | + |
| 79 | +=== Add Section 4.14 Conversions and Type Casting |
| 80 | + |
| 81 | +==== Add Section 4.14.1 Reinterpreting Data As Another Type |
| 82 | + |
| 83 | +Reinterpreting the bits of an object as an object of a different data type can |
| 84 | +be accomplished with the `sycl::bit_cast` function. This function has the same |
| 85 | +specification as `std::bit_cast`, defined by {cpp}20. |
| 86 | + |
| 87 | +[source,c++,`sycl::bit_cast`,linenums] |
| 88 | +---- |
| 89 | +namespace cl { |
| 90 | +namespace sycl { |
| 91 | + template<class To, class From> |
| 92 | + constexpr To bit_cast(const From& from) noexcept; |
| 93 | +} |
| 94 | +} |
| 95 | +---- |
| 96 | + |
| 97 | +|======================================== |
| 98 | +|Function|Description |
| 99 | +|+template<class To, class From> constexpr To bit_cast(const From& from) noexcept+ |
| 100 | +|Reinterprets the bits of an object of type `From` as an object of type `To`. Data types `To` and `From` must have the same size and must be trivially copyable. |
| 101 | +|======================================== |
| 102 | + |
| 103 | +== Issues |
| 104 | + |
| 105 | +None. |
| 106 | + |
| 107 | +== Revision History |
| 108 | + |
| 109 | +[cols="5,15,15,70"] |
| 110 | +[grid="rows"] |
| 111 | +[options="header"] |
| 112 | +|======================================== |
| 113 | +|Rev|Date|Author|Changes |
| 114 | +|1|2020-04-14|Felipe de Azevedo Piovezan|*Initial public working draft* |
| 115 | +|======================================== |
| 116 | + |
| 117 | +//************************************************************************ |
| 118 | +//Other formatting suggestions: |
| 119 | +// |
| 120 | +//* Use *bold* text for host APIs, or [source] syntax highlighting. |
| 121 | +//* Use +mono+ text for device APIs, or [source] syntax highlighting. |
| 122 | +//* Use +mono+ text for extension names, types, or enum values. |
| 123 | +//* Use _italics_ for parameters. |
| 124 | +//************************************************************************ |
0 commit comments