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
[ESIMD] Add infra to support half, bfloat, etc, support sycl::half. #5123
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any document which describes the concept of supporting non-standard types which you have implemented here? If not you should probably create one. That will greatly simplify things for maintainers of this code in future:)
namespace sycl { | ||
namespace ext { | ||
namespace intel { | ||
namespace experimental { | ||
namespace esimd { | ||
namespace detail { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: these namespaces can be collapsed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
// template <typename To, typename From, int N> | ||
// vector_type_t<To, N> convert(vector_type_t<From, N> Val) { | ||
// return convert<vector_type_t<To, N>>(Val); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this commented code can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
namespace sycl { | ||
namespace ext { | ||
namespace intel { | ||
namespace experimental { | ||
namespace esimd { | ||
namespace detail { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: these namespaces can be collapsed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
namespace esimd { | ||
namespace detail { | ||
|
||
enum class BinOp { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you forgot to add corresponding infra for unary ops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, will add
#ifdef __SYCL_DEVICE_ONLY__ | ||
using half = _Float16; | ||
#else | ||
using half = uint16_t; | ||
#endif // __SYCL_DEVICE_ONLY__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like these definitions are not used and can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right
ESIMD_INLINE DstWrapperTy convert_scalar(SrcWrapperTy Val) { | ||
if constexpr (std::is_same_v<SrcWrapperTy, DstWrapperTy>) { | ||
return Val; | ||
} else if constexpr (!detail::is_wrapper_elem_type_v<SrcWrapperTy> && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
detail:: can be removed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
} else if constexpr (!detail::is_wrapper_elem_type_v<SrcWrapperTy> && | ||
!detail::is_wrapper_elem_type_v<DstWrapperTy>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
detail:: can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
|
||
template <class T> using __st = element_storage_t<T>; | ||
|
||
#if 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this code under #if 0 is not needed anymore and thus need to be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, thanks for the catch
template <class T, class SFINAE> struct element_type_traits { | ||
// The raw element type of the underlying clang vector used as a | ||
// storage. | ||
using StorageT = invalid_storage_element_type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can probably rename StorageT to shorter RawT as you have used word 'raw' in many other places to describe storage type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
ok, will do |
@sndmitriev, all comments are fixed - please review |
@AlexeySachkov, please review sycl/include/CL/sycl/half_type.hpp |
// Meta-functions to compute compile-time element type of a simd_view resulting | ||
// from format operations. | ||
//===----------------------------------------------------------------------===// | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Content of this file was moved from types.hpp, mostly verbatim. The changes are noted below.
template <typename, int> class SimdT> | ||
struct compute_format_type<SimdT<Ty, N>, EltTy> | ||
: compute_format_type_impl<Ty, N, EltTy> {}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specialization for <simd_obj_impl<Ty, N, SimdT>, EltTy> was removed - not supposed to be used as argument
template <typename, int> class SimdT> | ||
struct compute_format_type_2d<SimdT<Ty, N>, EltTy, Height, Width> | ||
: compute_format_type_2d_impl<Ty, N, EltTy, Height, Width> {}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specialization for <simd_obj_impl<Ty, N, SimdT>, EltTy> was removed - not supposed to be used as argument
using simd_mask_storage_t = vector_type_t<simd_mask_elem_type, N>; | ||
// @{ | ||
// Checks if given type T derives from simd_obj_impl or is equal to it. | ||
template <typename T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved around the file due to factoring out some parts of types.hpp
|
||
// must match simd_mask<N>::element_type | ||
template <int N> | ||
using simd_mask_storage_t = vector_type_t<simd_mask_elem_type, N>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No functional changes in the code above (moved here from different part and renamed template parameter)
struct computation_type< | ||
T1, T2, std::enable_if_t<is_vectorizable_v<T1> && is_vectorizable_v<T2>>> { | ||
using type = decltype(std::declval<T1>() + std::declval<T2>()); | ||
// Determine element type of simd_obj_impl's Derived type w/o having to have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
314-331 is new code
Unrelated failures from SYCL / Default Linux / OCL x64 Test Suite (pull_request):
Unrelated failures from SYCL / Default Linux / HIP AMD GPU Test Suite (pull_request): all like this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
printf issues are fixed by intel/llvm-test-suite#685 I think |
what should I do then - ignore the failures?
ok, thanks |
- 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>
- fix vector conversion not to use CommonT - should result in fewer conversions and more in accordance to C++ - computation_type_t will now return sycl::half instead of _Float16 - Fix bug in simd(const SimdT &RHS) constructor - atomics are checked based on user type, not raw - EnclosingCppT for sycl::half is now _Float16 in device compiler - Few review comments addressed. Signed-off-by: Konstantin S Bobrovsky <konstantin.s.bobrovsky@intel.com>
Signed-off-by: Konstantin S Bobrovsky <konstantin.s.bobrovsky@intel.com>
- Add description of the non-std type support infra - Support unary ops in the infra - rename storage_type to raw_type - remove user_element_type - use element_type and raw_element_type instead of element_type and user_element_type Signed-off-by: Konstantin S Bobrovsky <konstantin.s.bobrovsky@intel.com>
Signed-off-by: Konstantin S Bobrovsky <konstantin.s.bobrovsky@intel.com>
Signed-off-by: Konstantin S Bobrovsky <konstantin.s.bobrovsky@intel.com>
Signed-off-by: Konstantin S Bobrovsky <konstantin.s.bobrovsky@intel.com>
Signed-off-by: Konstantin S Bobrovsky <konstantin.s.bobrovsky@intel.com>
Signed-off-by: Konstantin S Bobrovsky <konstantin.s.bobrovsky@intel.com>
When you merge with the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
half_type.hpp
changes LGTM
@dm-vodopyanov, @s-kanaev, @againull, @v-klochkov, @smaslov-intel - could you folks please review the only non-ESIMD change in the patch - sycl/include/CL/sycl/half_type.hpp - on behalf of llvm-reviewers-runtime? |
0c9fe3e
had to rebase and force-push to fix test failures (no code changes) |
to support a new type, the following must be implemented:
Complementary E2E tests update - intel/llvm-test-suite#640