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] Rework 'half' implementation in order to remove bunch of workarounds #1089

Merged
merged 3 commits into from
Feb 12, 2020

Conversation

AlexeySachkov
Copy link
Contributor

Because of the fact, that half type is not a standard C++ type and it is
not supported everywhere, its implementation differs between host and
device: C++ class with overloaded arithmetic operators is used on host
and _Float16 is used on device side.

Previously, the switch between two version was implemented as
preprocessor macro and having two different types caused some problems
with integration header and unnamed lambda feature, see #185 and
#960 (these patches are partially reverted in this PR).

This PR redesigned half implementation in a way, that single
wrapper data type is used as half representation on both host and
device sides; differentiation between actual host and device
implementations is done under the hood of this wrapper.

Copy link
Contributor

@KarachunIvan KarachunIvan left a comment

Choose a reason for hiding this comment

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

Overall LGTM

@s-kanaev s-kanaev changed the title Rework 'half' implementation in order to remove bunch of workarounds [SYCL] Rework 'half' implementation in order to remove bunch of workarounds Feb 4, 2020
@AlexeySachkov AlexeySachkov force-pushed the private/asachkov/redesign-half branch from b07dd2c to 970468a Compare February 7, 2020 16:27
Copy link
Contributor

@sergey-semenov sergey-semenov left a comment

Choose a reason for hiding this comment

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

LGTM aside from some nitpicks

sycl/include/CL/sycl/detail/generic_type_traits.hpp Outdated Show resolved Hide resolved
sycl/include/CL/sycl/half_type.hpp Outdated Show resolved Hide resolved
sycl/include/CL/sycl/half_type.hpp Outdated Show resolved Hide resolved
The only file left is
`sycl/test/regression/fp16-with-unnamed-lambda.cpp`

Signed-off-by: Alexey Sachkov <[email protected]>
Changes to tests are preserved

Signed-off-by: Alexey Sachkov <[email protected]>
Because of the fact, that `half` type is not a standard C++ type and it is
not supported everywhere, its implementation differs between host and
device: C++ class with overloaded arithmetic operators is used on host
and `_Float16` is used on device side.

Previously, the switch between two version was implemented as
preprocessor macro and having two different types caused some problems
with integration header and unnamed lambda feature, see intel#185 and
intel#960.

This patch redesigned `half` implementation in a way, that single
wrapper data type is used as `half` representation on both host and
device sides; differentiation between actual host and device
implementations is done under the hood of this wrapper.

Signed-off-by: Alexey Sachkov <[email protected]>
@AlexeySachkov AlexeySachkov force-pushed the private/asachkov/redesign-half branch from 970468a to 5d8ac20 Compare February 11, 2020 16:51
Copy link
Contributor

@Fznamznon Fznamznon left a comment

Choose a reason for hiding this comment

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

+1 for compiler changes.

@bader
Copy link
Contributor

bader commented Feb 12, 2020

Great work, @AlexeySachkov!

@bader bader merged commit e613fb3 into intel:sycl Feb 12, 2020
AlexeySachkov added a commit to AlexeySachkov/llvm that referenced this pull request Feb 18, 2020
Error was reproducible in two cases:
- using something like `numeric_limits<half>::min()` in within another
  `constexpr`
- not treating SYCL headers as system ones with `-Winvalid-constexpr`
  treated as error

Signed-off-by: Alexey Sachkov <[email protected]>
bader pushed a commit that referenced this pull request Feb 25, 2020
Error was reproducible in two cases:
- using something like `numeric_limits<half>::min()` in within another
  `constexpr`
- not treating SYCL headers as system ones with `-Winvalid-constexpr`
  treated as error

Signed-off-by: Alexey Sachkov <[email protected]>
@AlexeySachkov AlexeySachkov deleted the private/asachkov/redesign-half branch April 1, 2020 10:23
vmaksimo pushed a commit to vmaksimo/llvm that referenced this pull request Jul 5, 2021
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