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][COMPAT] Add math extend_v*4 to SYCLCompat #14078

Merged
merged 28 commits into from
Jun 12, 2024

Conversation

OuadiElfarouki
Copy link
Contributor

This PR adds math extend_v*4 operators (18 in total) along with unit-tests for signed and unsigned int32 cases.
*Some changes overlap with the previous extend_v*2 PR #13953 and thus should be reviewed/merged first.

Copy link
Contributor

@joeatodd joeatodd left a comment

Choose a reason for hiding this comment

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

Hey @OuadiElfarouki nice work! Just a couple comments just now - to replace enable_if w/ static_assert. Apologies again for sending you the wrong way!

I notice the test math_extend_v.cpp is very slow (284 seconds when I run it locally). I'll investigate that further.

sycl/include/syclcompat/math.hpp Outdated Show resolved Hide resolved
sycl/include/syclcompat/math.hpp Outdated Show resolved Hide resolved
Copy link
Contributor

@Alcpz Alcpz left a comment

Choose a reason for hiding this comment

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

LGTM

@OuadiElfarouki
Copy link
Contributor Author

@intel/llvm-gatekeepers PR is ready for merge 🙏🏻
Also CI memory_management.cpp failure is being tracked in Issue #14086
Thanks!

@steffenlarsen
Copy link
Contributor

@joeatodd has requested a change to this PR and as such will need to approve before we can go ahead.

Co-authored-by: Yihan Wang <yihan.wang@intel.com>
typename BinaryOperation>
inline constexpr RetT extend_vbinary4(AT a, BT b, RetT c,
BinaryOperation binary_op) {
static_assert(std::is_integral_v<AT> && std::is_integral_v<BT> &&
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can simplify to check whether AT and BT is int32_t/uint32_t, WDYT?

template <class T>
constexpr inline bool is_i32_or_u32 = std::is_same_v<std::decay_t<T>, int32_t> || 
                                      std::is_same_v<std::decay_t<T>, uint32_t>;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that should look better @yihanwg. We don't want to put it inside the detail namespace though, any suggestion?

int16_t min_val = 0, max_val = 0;
min_val = std::numeric_limits<Tint>::min();
max_val = std::numeric_limits<Tint>::max();
temp = detail::clamp(temp, {min_val, min_val, min_val, min_val},
Copy link
Contributor

Choose a reason for hiding this comment

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

We can use the following code to construct a 4 element min_val/max_val vector.
https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#_vec_interface
explicit constexpr vec(const DataT& arg);

sycl::vec<int16_t, 4>(min_val), sycl::vec<int16_t, 4>(max_val)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will apply for the v2 variant as well (just to keep it consistent, as the v2 extend got merged already).

Copy link
Contributor

@joeatodd joeatodd left a comment

Choose a reason for hiding this comment

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

LGTM

@OuadiElfarouki
Copy link
Contributor Author

@intel/llvm-gatekeepers PR is ready! Thank you.

@steffenlarsen steffenlarsen merged commit da735fe into intel:sycl Jun 12, 2024
14 checks passed
ianayl pushed a commit to ianayl/sycl that referenced this pull request Jun 13, 2024
This PR adds math `extend_v*4` operators (18 in total) along with
unit-tests for signed and unsigned int32 cases.
*Some changes overlap with the previous `extend_v*2` PR intel#13953 and thus
should be reviewed/merged first.

---------

Co-authored-by: Alberto Cabrera Pérez <alberto.cabrera@intel.com>
Co-authored-by: Joe Todd <joe.todd@codeplay.com>
Co-authored-by: Yihan Wang <yihan.wang@intel.com>
steffenlarsen pushed a commit that referenced this pull request Jun 14, 2024
This PR adds math `extend_vcompare[2/4] `operators (4 in total) along
with unit-tests for signed and unsigned int32 cases.
Also, Unit-tests from previous `extend_v*4` #14078 and `extend_v*2`
#13953 are moved to two different files.

---------

Co-authored-by: Alberto Cabrera Pérez <alberto.cabrera@intel.com>
Co-authored-by: Joe Todd <joe.todd@codeplay.com>
Co-authored-by: Yihan Wang <yihan.wang@intel.com>
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.

6 participants