Skip to content

[SYCL] add preliminary support for bfloat16 to sycl::vec #12261

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 23 commits into from
Jan 25, 2024

Conversation

cperkinsintel
Copy link
Contributor

This does not yet add support for the math builtins for sycl::vec<bfloat16> . That will come later.

Copy link
Contributor

github-actions bot commented Dec 28, 2023

✅ With the latest revision this PR passed the C/C++ code formatter.

@cperkinsintel cperkinsintel marked this pull request as ready for review January 3, 2024 19:47
@cperkinsintel cperkinsintel requested review from a team as code owners January 3, 2024 19:47
@dkhaldi
Copy link
Contributor

dkhaldi commented Jan 19, 2024

Does this change enable sub_group::load and sub_group::store (https://github.com/intel/llvm/blob/sycl/sycl/include/sycl/sub_group.hpp#L71) to work on bfloat16 type?
If yes, it will be good to add an example of these two instructions in one of the tests you added.

@cperkinsintel
Copy link
Contributor Author

@dkhaldi - I did a quick test of using sub_groups to .load() data from one buffer and modify and .store() it into another, and this works with bfloat16 in the current source base. So, if you are asking if this PR would enable that behavior, the answer is "no" - it's already present and working. AFAICT.

But maybe I'm misunderstanding your inquiry?

I also checked using sub_groups to .load()/.store() for sycl::vec<bfloat16> and that now compiles and works with this PR, whereas before it, it would not (obviously). Are you sure we need testing for this? I strongly suspect the contexts of your inquiry and my answer are not the same.

@dkhaldi
Copy link
Contributor

dkhaldi commented Jan 19, 2024

I also checked using sub_groups to .load()/.store() for sycl::vec<bfloat16> and that now compiles and works with this PR, whereas before it, it would not (obviously). Are you sure we need testing for this? I strongly suspect the contexts of your inquiry and my answer are not the same.

Sorry I was not specific, Yes, I meant this latter. sub_group::load/store on sycl::vec of type bfloat16.
Good to know that your PR enables that.
I think it will be good to add that in the test since your PR enables it.

Copy link
Contributor

@aelovikov-intel aelovikov-intel left a comment

Choose a reason for hiding this comment

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

Looks much better now, but I've had too many iterations reviewing this that some things might have become invisible to my eye. @steffenlarsen , @sergey-semenov , would you mind having a look through it as well?

@cperkinsintel
Copy link
Contributor Author

@intel/dpcpp-tools-reviewers could I get one of you to review?

Copy link
Contributor

@dkhaldi dkhaldi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@AlexeySachkov AlexeySachkov left a comment

Choose a reason for hiding this comment

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

Not sure why bfloat16 E2E test are owned by tools team, but changes LGTM

@@ -142,20 +144,61 @@ using select_apply_cl_t = std::conditional_t<
template <typename T> struct vec_helper {
using RetType = T;
static constexpr RetType get(T value) { return value; }
static constexpr RetType set(T value) { return value; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit; I am not much for the name "set". What does it set? "get" isn't great for that matter, but it sounds more and more like we are mutating something, which we are not.

return std::array<DataT_, 1>{vec_data<DataT_>::get(static_cast<DataT_>(A))};
#else
return std::array<DataT_, 1>{vec_data<DataT_>::get(A)};
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason we can promote this out of preview now? Was it just a mistake to have it under preview before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. It was a mistake and shouldn't have been there to begin with.

@againull againull merged commit bbbe883 into intel:sycl Jan 25, 2024
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.

None yet

6 participants