-
Notifications
You must be signed in to change notification settings - Fork 18k
[libclc] Refine __clc_fp*_subnormals_supported #157633
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
Changes from 17 commits
7e2d210
96ec9dc
d52fcdb
4608f77
3f665ce
7b290a2
3da9705
7d21a1a
b61e32b
ccf7a6e
23d0ff7
ddb79ae
3e2ac98
34cd062
b14455b
7757ba0
fe2d4f6
7ff4dcf
5eb6990
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include <clc/internal/clc.h> | ||
| #include <clc/math/clc_subnormal_config.h> | ||
|
|
||
| #ifdef cl_khr_fp16 | ||
| #pragma OPENCL EXTENSION cl_khr_fp16 : enable | ||
| _CLC_DEF bool __clc_fp16_subnormals_supported() { | ||
| // SPIR-V doesn't support llvm.canonicalize. Synthesize a subnormal by halving | ||
| // the smallest normal. If subnormals are not supported it will flush to +0. | ||
| half smallest_normal = 0x1p-14h; | ||
| half sub = | ||
| smallest_normal * 0.5h; // Expected 0x1p-15h (subnormal) if supported | ||
| return !__builtin_isfpclass(sub, __FPCLASS_POSZERO); | ||
| } | ||
| #endif // cl_khr_fp16 | ||
|
|
||
| _CLC_DEF bool __clc_fp32_subnormals_supported() { | ||
| // SPIR-V doesn't support llvm.canonicalize. Synthesize a subnormal by halving | ||
| // the smallest normal. If subnormals are not supported it will flush to +0. | ||
| float smallest_normal = 0x1p-126f; | ||
| float sub = | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need multiply, and I think this logic should be inverted. Denormal support is the base case, DAZ is an aberration. i.e., this is what I did in device-libs is about
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reverted |
||
| smallest_normal * 0.5f; // Expected 0x1p-127f (subnormal) if supported | ||
| return !__builtin_isfpclass(sub, __FPCLASS_POSZERO); | ||
| } | ||
|
|
||
| #ifdef cl_khr_fp64 | ||
| #pragma OPENCL EXTENSION cl_khr_fp64 : enable | ||
| _CLC_DEF bool __clc_fp64_subnormals_supported() { | ||
| // SPIR-V doesn't support llvm.canonicalize. Synthesize a subnormal by halving | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix SPIRV, this is not a reasonable workaround. This is not a difficult to implement intrinsic
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed SPIRV path to use __clc_fabs(0x1p-149f) in 7ff4dcf
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've made an attempt to add the lowering in #178439 |
||
| // the smallest normal. If subnormals are not supported it will flush to +0. | ||
| double smallest_normal = 0x1p-1022; | ||
| double sub = | ||
| smallest_normal * 0.5; // Expected 0x1p-1023 (subnormal) if supported | ||
| return !__builtin_isfpclass(sub, __FPCLASS_POSZERO); | ||
| } | ||
| #endif // cl_khr_fp64 | ||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.