Skip to content
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

[SYCL] Add marray support to common + some math functions #8631

Merged

Conversation

dm-vodopyanov
Copy link
Contributor

@dm-vodopyanov dm-vodopyanov commented Mar 13, 2023

This patch adds marray support to all functions from Table 179 of SYCL 2020 spec + to functions fabs, ilogb, fmax, fmin, ldexp, pown, rootn from Table 175 + to function exp10 from Table 177.

E2E tests: intel/llvm-test-suite#1656

This patch adds marray support to all functions from Table 179 of SYCL 2020
spec + to functions fabs, ilogb, fmax, fmin, ldexp, pown, rootn from
Table 175 + to function exp10 from Table 177.
@dm-vodopyanov
Copy link
Contributor Author

/verify with intel/llvm-test-suite#1656

@dm-vodopyanov dm-vodopyanov temporarily deployed to aws March 13, 2023 14:24 — with GitHub Actions Inactive
@dm-vodopyanov dm-vodopyanov temporarily deployed to aws March 13, 2023 14:53 — with GitHub Actions Inactive
template <typename T, size_t N>
inline __SYCL_ALWAYS_INLINE
std::enable_if_t<detail::is_sgenfloat<T>::value, marray<T, N>>
pown(marray<T, N> x, marray<int, N> y) __NOEXC {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we can add one more high-level macro to generalize definitions of pown, rootn and ldexp. Similar to __SYCL_MATH_FUNCTION_2_OVERLOAD(atan2)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically yes, the reason I didn't do this is to stick to code style in this part of the file.

@@ -122,10 +122,27 @@ __SYCL_MATH_FUNCTION_OVERLOAD_FM(log2)
__SYCL_MATH_FUNCTION_OVERLOAD_FM(log10)
__SYCL_MATH_FUNCTION_OVERLOAD_FM(sqrt)
__SYCL_MATH_FUNCTION_OVERLOAD_FM(rsqrt)
__SYCL_MATH_FUNCTION_OVERLOAD_FM(fabs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to outline such tiny additions into a separate PR, because we can merge them almost right away.

@AlexeySachkov AlexeySachkov requested a review from a team March 14, 2023 11:27
@dm-vodopyanov
Copy link
Contributor Author

/verify with intel/llvm-test-suite#1656

@KornevNikita KornevNikita temporarily deployed to aws March 15, 2023 14:12 — with GitHub Actions Inactive
@KornevNikita KornevNikita temporarily deployed to aws March 15, 2023 14:42 — with GitHub Actions Inactive
@KornevNikita KornevNikita temporarily deployed to aws March 16, 2023 08:57 — with GitHub Actions Inactive
@KornevNikita
Copy link
Contributor

/verify with intel/llvm-test-suite#1656

@KornevNikita KornevNikita temporarily deployed to aws March 16, 2023 18:48 — with GitHub Actions Inactive
@KornevNikita KornevNikita temporarily deployed to aws March 16, 2023 20:01 — with GitHub Actions Inactive
@KornevNikita
Copy link
Contributor

@bader @AlexeySachkov lol, now clang-format suggests to get these suspicious changes back. Should I apply them or I can just add ignore-lint label?

@bader
Copy link
Contributor

bader commented Mar 17, 2023

@bader @AlexeySachkov lol, now clang-format suggests to get these suspicious changes back. Should I apply them or I can just add ignore-lint label?

I'm against ignoring formatting issues in the code we own. If you prefer to keep existing formatting, you can disable clang-format for some parts. https://clang.llvm.org/docs/ClangFormatStyleOptions.html#disabling-formatting-on-a-piece-of-code

Some suggestions look reasonable. E.g.

@@ -182,9 +182,8 @@ __SYCL_MATH_FUNCTION_2_OVERLOAD(remainder)
 template <typename T, size_t N>
 inline __SYCL_ALWAYS_INLINE
     std::enable_if_t<__FAST_MATH_SGENFLOAT(T), marray<T, N>>
-    powr(marray<T, N> x, marray<T, N> y) __NOEXC {
-  __SYCL_MATH_FUNCTION_2_OVERLOAD_IMPL(powr)
-}
+    powr(marray<T, N> x,
+         marray<T, N> y) __NOEXC{__SYCL_MATH_FUNCTION_2_OVERLOAD_IMPL(powr)}

Do you know why clang-format gives different results? I know that the version must be the same, so I suppose there were changes in the config file. Right?

@KornevNikita
Copy link
Contributor

@bader honestly I don't know.

This one definitely looks strange:

 __SYCL_MATH_FUNCTION_2_SGENFLOAT_Y_OVERLOAD(fmax)
-__SYCL_MATH_FUNCTION_2_SGENFLOAT_Y_OVERLOAD(fmin)
+    __SYCL_MATH_FUNCTION_2_SGENFLOAT_Y_OVERLOAD(fmin)
 
 #undef __SYCL_MATH_FUNCTION_2_SGENFLOAT_Y_OVERLOAD
 
-template <typename T, size_t N>
-inline __SYCL_ALWAYS_INLINE
-    std::enable_if_t<detail::is_sgenfloat<T>::value, marray<T, N>>
-    ldexp(marray<T, N> x, marray<int, N> k) __NOEXC {
+        template <typename T, size_t N>
+        inline __SYCL_ALWAYS_INLINE
+    std::enable_if_t<detail::is_sgenfloat<T>::value, marray<T, N>> ldexp(
+        marray<T, N> x, marray<int, N> k) __NOEXC {

I'm okay to apply these suggestions if you think that this formatting is right.

@bader
Copy link
Contributor

bader commented Mar 17, 2023

This should be the decision of the code owners. I've given you options on how to keep the existing formatting so you can change it, keep it, or mix these options.

 -__SYCL_MATH_FUNCTION_2_SGENFLOAT_Y_OVERLOAD(fmax)
 -__SYCL_MATH_FUNCTION_2_SGENFLOAT_Y_OVERLOAD(fmin)
 +    __SYCL_MATH_FUNCTION_2_SGENFLOAT_Y_OVERLOAD(fmin)

My personal view is that this change makes formatting inconsistent, so wouldn't apply it. I suppose ldexp declaration formatting is off because of this misalignment with macro.

This reverts commit 23cfc1e.
@KornevNikita KornevNikita temporarily deployed to aws March 17, 2023 18:59 — with GitHub Actions Inactive
@KornevNikita KornevNikita temporarily deployed to aws March 17, 2023 20:08 — with GitHub Actions Inactive
@KornevNikita
Copy link
Contributor

/verify with intel/llvm-test-suite#1656

@AlexeySachkov
Copy link
Contributor

@bader @AlexeySachkov lol, now clang-format suggests to get these suspicious changes back. Should I apply them or I can just add ignore-lint label?

Current formatting looks good to me and I would prefer not to revert back to the weird one

@AlexeySachkov
Copy link
Contributor

@againull, @intel/llvm-reviewers-runtime, could you please take a look?

@KornevNikita
Copy link
Contributor

/verify with intel/llvm-test-suite#1656

@AlexeySachkov AlexeySachkov merged commit c5c7ac2 into intel:sycl Mar 21, 2023
dm-vodopyanov added a commit to dm-vodopyanov/llvm that referenced this pull request Mar 31, 2023
This patch adds support of sycl::marray to the rest math built-in
functions (SYCL 2020, Table 175), and adds missing tests for math and
common functions for intel#8631 to reduce
number of upcoming cherry-picks.
dm-vodopyanov added a commit that referenced this pull request Apr 6, 2023
This patch adds support of sycl::marray to the rest of math built-in
functions (SYCL 2020, Table 175), and adds missing tests for math and
common functions for #8631 to reduce
number of upcoming cherry-picks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants