Skip to content

Commit

Permalink
[ESIMD] Add infra to support half, bfloat, etc, support sycl::half. (#…
Browse files Browse the repository at this point in the history
…5123)

- implement infrastructure for non-standard element type support
  to support a new type, the following must be implemented:
  * element type traits for the new type
  * scalar and vector conversions to/from selected std C++ type
  * std operations (or default with promotion to std C++ type can be used)
- esimd::simd<sycl::half, N> can now be used on host and device
  * most of the operations, except extended math are supported for half

Signed-off-by: Konstantin S Bobrovsky <konstantin.s.bobrovsky@intel.com>
  • Loading branch information
kbobrovs authored Dec 28, 2021
1 parent 27f59d8 commit f34ba2c
Show file tree
Hide file tree
Showing 17 changed files with 1,554 additions and 670 deletions.
19 changes: 19 additions & 0 deletions sycl/include/CL/sycl/half_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {

namespace ext {
namespace intel {
namespace experimental {
namespace esimd {
namespace detail {
class WrapperElementTypeProxy;
} // namespace detail
} // namespace esimd
} // namespace experimental
} // namespace intel
} // namespace ext

namespace detail {

inline __SYCL_CONSTEXPR_HALF uint16_t float2Half(const float &Val) {
Expand Down Expand Up @@ -255,6 +268,9 @@ class __SYCL_EXPORT half_v2 {
// Initialize underlying data
constexpr explicit half_v2(uint16_t x) : Buf(x) {}

friend class sycl::ext::intel::experimental::esimd::detail::
WrapperElementTypeProxy;

private:
uint16_t Buf;
};
Expand Down Expand Up @@ -391,6 +407,9 @@ class half {

template <typename Key> friend struct std::hash;

friend class sycl::ext::intel::experimental::esimd::detail::
WrapperElementTypeProxy;

private:
StorageT Data;
};
Expand Down
6 changes: 6 additions & 0 deletions sycl/include/sycl/ext/intel/experimental/esimd/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#define ESIMD_REGISTER(n) __attribute__((register_num(n)))

#define __ESIMD_API ESIMD_NODEBUG ESIMD_INLINE

#define __ESIMD_UNSUPPORTED_ON_HOST

#else // __SYCL_DEVICE_ONLY__
#define SYCL_ESIMD_KERNEL
#define SYCL_ESIMD_FUNCTION
Expand All @@ -41,6 +44,9 @@
#define ESIMD_REGISTER(n)

#define __ESIMD_API ESIMD_INLINE

#define __ESIMD_UNSUPPORTED_ON_HOST throw cl::sycl::feature_not_supported()

#endif // __SYCL_DEVICE_ONLY__

// Mark a function being noinline
Expand Down
Loading

0 comments on commit f34ba2c

Please sign in to comment.