Skip to content

[SYCL][libdevice] Add SIMD emulation APIs for imf libdevice #6327

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

Merged
merged 19 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libdevice/cmake/modules/ImfSrcConcate.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
set(imf_fp32_fallback_src_list imf_utils/integer_misc.cpp
imf_utils/half_convert.cpp
imf_utils/float_convert.cpp
imf_utils/simd_emulate.cpp
imf/imf_inline_fp32.cpp)

set(imf_fp64_fallback_src_list imf_utils/double_convert.cpp
Expand Down
1 change: 1 addition & 0 deletions libdevice/cmake/modules/SYCLLibdevice.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ set(imf_fallback_fp32_deps device.h device_imf.hpp imf_half.hpp
imf_utils/integer_misc.cpp
imf_utils/float_convert.cpp
imf_utils/half_convert.cpp
imf_utils/simd_emulate.cpp
imf/imf_inline_fp32.cpp)
set(imf_fallback_fp64_deps device.h device_imf.hpp imf_half.hpp
imf_utils/double_convert.cpp
Expand Down
17 changes: 13 additions & 4 deletions libdevice/device_imf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "device.h"
#include "imf_half.hpp"
#include <cstddef>
#include <limits>
#include <type_traits>

#ifdef __LIBDEVICE_IMF_ENABLED__

#if !defined(__SPIR__) && !defined(__LIBDEVICE_HOST_IMPL__)
Expand Down Expand Up @@ -458,12 +458,21 @@ static inline int __popcll(unsigned long long int x) {
#endif
}

static inline unsigned int __abs(int x) { return x < 0 ? -x : x; }

static inline unsigned long long int __abs(long long int x) {
template <typename T>
static inline typename std::make_unsigned<T>::type __abs(T x) {
static_assert((std::is_signed<T>::value && std::is_integral<T>::value),
"__abs can only accept signed integral type.");
return x < 0 ? -x : x;
}

template <typename T> static inline void __swap(T &x, T &y) {
static_assert(std::is_integral<T>::value,
"__swap can only accept integral type.");
T tmp = x;
x = y;
y = tmp;
}

template <typename Ty1, typename Ty2>
static inline Ty2 __get_bytes_by_index(Ty1 x, size_t idx) {
static_assert(!std::is_signed<Ty1>::value && !std::is_signed<Ty2>::value,
Expand Down
Loading