Skip to content

[SYCL] Add aspect for bfloat16 #5720

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 11 commits into from
Jun 13, 2022
Merged

[SYCL] Add aspect for bfloat16 #5720

merged 11 commits into from
Jun 13, 2022

Conversation

AidanBeltonS
Copy link
Contributor

@AidanBeltonS AidanBeltonS commented Mar 3, 2022

This PR adds a new aspect ext_oneapi_bfloat16 to allow a runtime check for if the device supports the bfloat16 floating point type.
Only the CUDA implementation for checking if the device supports this aspect is added.

Updated test: intel/llvm-test-suite#888

@steffenlarsen
Copy link
Contributor

I do not see the bf16 aspect in the SYCL 2020 specification. If this is an extension it should be named accordingly and may need documentation.

@MrSidims MrSidims self-requested a review March 3, 2022 12:31
@MrSidims
Copy link
Contributor

MrSidims commented Mar 3, 2022

I do not see the bf16 aspect in the SYCL 2020 specification. If this is an extension it should be named accordingly and may need documentation.

There is actually an extension, but bf16 aspect there is known under different name. @AidanBeltonS can these names be united?

@AidanBeltonS
Copy link
Contributor Author

I do not see the bf16 aspect in the SYCL 2020 specification. If this is an extension it should be named accordingly and may need documentation.

There is actually an extension, but bf16 aspect there is known under different name. @AidanBeltonS can these names be united?

Yes, ideally we would unite the two aspects.
Currently the ext_intel_bf16_conversion aspect is not backend agnostic.
Unifying the two would be good as it would generalize the existing aspect so that it can be used by other backends.

I think this has been discussed a bit before: #5645 (comment)

Copy link
Contributor

@s-kanaev s-kanaev left a comment

Choose a reason for hiding this comment

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

Other than the comments, the change LGTM.

@@ -49,6 +49,7 @@ enum class aspect {
ext_oneapi_native_assert = 31,
host_debuggable = 32,
ext_intel_gpu_hw_threads_per_eu = 33,
bf16 = 34
Copy link
Contributor

Choose a reason for hiding this comment

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

To reduce changes in future:

Suggested change
bf16 = 34
bf16 = 34,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -4288,6 +4288,7 @@ _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE65808EEENS3_12param_traitsIS4_XT_
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE65809EEENS3_12param_traitsIS4_XT_EE11return_typeEv
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE65810EEENS3_12param_traitsIS4_XT_EE11return_typeEv
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE69632EEENS3_12param_traitsIS4_XT_EE11return_typeEv
_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE73728EEENS3_12param_traitsIS4_XT_EE11return_typeEv
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably, a PATCH version in CMakeLists should be incremented to denote a non-breaking change. @alexbatashev , please, correct me if I'm wrong.
Please, refer to https://github.com/intel/llvm/blob/sycl/sycl/doc/developer/ABIPolicyGuide.md#abi-versioning-policy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure if the PATCH version should be updated as in the abi-versioning-policy docs it states. MAJOR, MINOR, and PATCH versions are not updated between releases.

@AidanBeltonS AidanBeltonS requested a review from a team as a code owner March 9, 2022 09:57
@@ -1,4 +1,4 @@
= SYCL_INTEL_bf16_conversion
= SYCL_ONEAPI_bfloat16
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 your branch must be out-of-date because these specification file names are now all lower case. You should merge the base and resolve conflicts (or maybe it will just be easier to start a new PR).

The name of the file should stay in sync with the feature-test macro. Since you are renaming the feature-test macro to "SYCL_EXT_ONEAPI_BFLOAT16_CONVERSION", the file name should be "sycl_ext_oneapi_bfloat16_conversion.asciidoc". The name of the extension (on line 1 of this file) should also be lowercase: "sycl_ext_oneapi_bfloat16_conversion".

However, maybe you are preparing this extension to encompass all bfloat16 features, rather than just conversion? As I mentioned in #5645, I think it would be better to have a single bloat16 extension like this. In that case, the name of the feature-test macro should be "SYCL_EXT_ONEAPI_BFLOAT16", the name of the extension should be "sycl_ext_oneapi_bfloat16", and the name of the file should be "sycl_ext_oneapi_bfloat16.asciidoc".

Finally, the header file "include/CL/sycl/feature_test.hpp" should also be updated to define the new feature-test macro, and you should remove the definition of the old feature-test macro.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No changes to the extension are in this PR anymore. The extension was updated by #5393.
So the new aspect is inline with the the extension

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. I think this looks good.

@smaslov-intel, do you want a chance to review this from the implementation point of view?

@@ -317,6 +317,7 @@ typedef enum {
PI_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES = 0x11000,
PI_DEVICE_INFO_GPU_HW_THREADS_PER_EU = 0x10112,
PI_DEVICE_INFO_BACKEND_VERSION = 0x10113,
PI_EXT_ONEAPI_DEVICE_INFO_BFLOAT16 = 0x12000,
Copy link
Contributor

@smaslov-intel smaslov-intel May 16, 2022

Choose a reason for hiding this comment

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

Let's not create more than necessary gaps in numbering. Please use 0x1FFFF

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay thanks. I have updated the value

@smaslov-intel
Copy link
Contributor

Why don't you add a test for real "bfloat16" support, if the aspect is reported?

@AidanBeltonS
Copy link
Contributor Author

Why don't you add a test for real "bfloat16" support, if the aspect is reported?

Could you clarify what you mean by this? Finding out if the device supports bfloat16 is backend dependent and involves calling native CUDA functions.
I have also added a test in the llvm-test-suite that checks if the aspect can be used.

@smaslov-intel
Copy link
Contributor

I have also added a test in the llvm-test-suite that checks if the aspect can be used.

Can you also add a test that really uses bfloat16 after the aspect check returns true?

@AidanBeltonS
Copy link
Contributor Author

Can you also add a test that really uses bfloat16 after the aspect check returns true?

Yes, I have made a change to BFloat16/bfloat16_type_cuda.cpp to run the test after the aspect returns true.

@AidanBeltonS
Copy link
Contributor Author

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

@pvchupin pvchupin requested review from smaslov-intel and removed request for AlexeySotkin June 8, 2022 00:00
smaslov-intel
smaslov-intel previously approved these changes Jun 8, 2022
@pvchupin
Copy link
Contributor

@AidanBeltonS, can you fix conflicts please?

@AidanBeltonS
Copy link
Contributor Author

@AidanBeltonS, can you fix conflicts please?

I have resolved all conflicts.

@pvchupin pvchupin merged commit f84fc32 into intel:sycl Jun 13, 2022
pvchupin pushed a commit to intel/llvm-test-suite that referenced this pull request Jun 13, 2022
This PR adds the bf16 aspect to aspects.cpp test.

Depends on: intel/llvm#5720
steffenlarsen added a commit to steffenlarsen/llvm that referenced this pull request Jun 14, 2022
intel#5720 added a new specialization of
get_info for info::device::ext_oneapi_bfloat16 but no Windows symbol was
added to the dump file. This commit adds the missing symbol.

Signed-off-by: Larsen, Steffen <[email protected]>
pvchupin pushed a commit that referenced this pull request Jun 14, 2022
#5720 added a new specialization of
get_info for info::device::ext_oneapi_bfloat16 but no Windows symbol was
added to the dump file. This commit adds the missing symbol.

Signed-off-by: Larsen, Steffen <[email protected]>
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Mar 27, 2023
This PR adds the bf16 aspect to aspects.cpp test.

Depends on: intel#5720
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.

7 participants